package ss.pku.jsa.worklist.algorithm;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;

import ss.pku.jsa.worklist.WorkListTemplate;
import ss.pku.jsa.worklist.om.Constraint;
import ss.pku.jsa.worklist.om.Expression;
import ss.pku.jsa.worklist.om.Value;

public class FIFOWorkList<M, K> extends WorkListTemplate<M, K> {

	private Queue<Constraint<M,K>> queue;
	
	public FIFOWorkList(Constraint<M, K>[] constraints) {
		super(constraints);
		queue = new LinkedList<Constraint<M,K>>();
	}

	@Override
	public Set<Value<M, K>> eval(Constraint<M, K> constraint) {
		Expression<M, K> exp = constraint.getRight();
		return exp.evaluate();
	}

	@Override
	public void insert(Constraint<M, K> constraint) {
		queue.offer(constraint);
	}

	@Override
	public Constraint<M, K> extract() {
		return queue.poll();
	}

}
